/*
 * TagFactory.cpp
 *
 *  Created on: 19 juin 2011
 *      Author: Pierrick Caillon <pierrick@megami.fr>
 */

#include "TagFactory.h"
#include "TagEnd.h"
#include "TagByte.h"
#include "TagShort.h"
#include "TagInt.h"
#include "TagLong.h"
#include "TagFloat.h"
#include "TagDouble.h"
#include "TagByteArray.h"
#include "TagString.h"
#include "TagList.h"
#include "TagCompound.h"

/* NUMERICVALUE_H_ */
/* TAGBYTE_H_ */
/* NUMERICVALUE_H_ */
/* TAGSHORT_H_ */
/* NUMERICVALUE_H_ */
/* TAGINT_H_ */
/* NUMERICVALUE_H_ */
/* NUMERICVALUE_H_ */
/* TAGFLOAT_H_ */
/* NUMERICVALUE_H_ */
/* TAGDOUBLE_H_ */
namespace NamedBinaryTag
{
    ITag *TagFactory::CreateTag(TagTypes type)
    {
        ITag *tag = NULL;
        switch (type)
	{
	case TAG_END:
		tag = new TagEnd();
		break;
	case TAG_BYTE:
		tag = new TagByte();
		break;
	case TAG_SHORT:
		tag = new TagShort();
		break;
	case TAG_INT:
		tag = new TagInt();
		break;
	case TAG_LONG:
		tag = new TagLong();
		break;
	case TAG_FLOAT:
		tag = new TagFloat();
		break;
	case TAG_DOUBLE:
		tag = new TagDouble();
		break;
	case TAG_BYTEARRAY:
		tag = new TagByteArray();
		break;
	case TAG_STRING:
		tag = new TagString();
		break;
	case TAG_LIST:
		tag = new TagList();
		break;
	case TAG_COMPOUND:
		tag = new TagCompound();
		break;
	default:
		std::__throw_out_of_range(
				__N("TagFactory::createTag: Tag type not defined."));
	}
        return tag;
    }

    void TagFactory::DeleteTag(ITag *tag)
    {
    	if (tag != NULL)
    		delete tag;
    }

}
